<template>
  <div class="linenRinse-content">
          <div class="linenRinseBox">
                <div class="headerBox">
                      <div class="line"></div>
                      <div class="title">{{type==='INBOUND'?'查看入库记录':'查看出库记录'}}</div>
                </div>
               <div v-if="type==='INBOUND'">
                     <el-table :data="infoList" border>
                        <el-table-column label="名称" align="center" prop="equipmentName" />
                        <el-table-column label="产商" align="center" prop="manufacturer" />
                        <el-table-column label="发票" align="center" prop="case" >
                        <template slot-scope="scope">
                                  <div class="preview">
                                     <el-image class="image" fit="cover" :src="infoList.invoiceFileUrl[0]" :preview-src-list="infoList.invoiceFileUrl"></el-image>
                                  </div>
                            </template>
                         </el-table-column >
                        <el-table-column label="批号" align="center" prop="batchNumber" />
                        <el-table-column label="生产标准" align="center" prop="productionStandards" />
                        <el-table-column label="入库时间" align="center" prop="entryTime" />          
                     </el-table>
               </div>
                <div v-if="type==='OUTBOUND'">
                     <el-table :data="infoList" border>
                        <el-table-column label="名称" align="center" prop="equipmentName" />
                        <el-table-column label="批号" align="center" prop="batchNumber" />
                        <el-table-column label="使用车间" align="center" prop="workshop" />
                        <el-table-column label="数量" align="center" prop="num" />
                        <el-table-column label="分发时间" align="center" prop="outboundTime" />          
                     </el-table>
               </div>
                <pagination
                  v-show="total>0"
                  :total="total"
                  :page.sync="queryParams.pageNum"
                  :limit.sync="queryParams.pageSize"
                  @pagination="getLibraryListFn"
               />
                <div class="bottomBtnCss">
                  <el-button @click="goBackBtn">返回</el-button>
                 </div>
          </div>
  </div>
</template>

<script>
import { getStorageRecord,getOutboundRecord} from "@/api/zhangping/occupational";
  export default {
    data() {
      return {
         type:'',
         infoList:[],
         queryParams:{
              creditCode:'', 
              pageNum: 1,
              pageSize: 10,
         },
         total:0
      };
    },
    created() {
        this.type = this.$route.query.type
        this.queryParams.creditCode = this.$route.query.creditCode 
        this.getLibraryListFn()
    },
    methods: {
       getLibraryListFn(){ 
                let type = this.type         
                switch(type){
                case 'INBOUND': 
                      this.getStorageRecordFn()
                break;
                case 'OUTBOUND': 
                      this.getOutboundRecordFn()
                break;
                default: 
                break; 
           }     
      },

      getStorageRecordFn(){
            getStorageRecord(this.queryParams).then(res=>{
                  if(res.code == 200){
                        this.infoList = res.rows
                         this.infoList.invoiceFileUrl = [res.rows.invoiceFileUrl]
                        this.total = res.total
                  }else{
                        this.$message.error(res.msg);  
                  }    
            })
        },

        getOutboundRecordFn(){
            getOutboundRecord(this.queryParams).then(res=>{
                  if(res.code == 200){
                        this.infoList = res.rows
                        this.total = res.total
                  }else{
                        this.$message.error(res.msg);  
                  }    
            })
        },
         
        goBackBtn(){
          this.$router.back()
        },
    }
  };
</script>
<style lang="scss" scoped>
         .display-fx-center{
             display: flex;
             align-items: center;
         }
         .per100{
             width: 100%!important;
         }
         .soildTop{
             border-top:solid 1px  #D3D8E2;
         }
         .linenRinse-content{
              overflow-y: auto;
              position: relative;
              background-color: #fff;
              padding: 40px 20px;
              border-radius: 10px;
              height: calc( 100vh - 66px - 40px);
             .linenRinseBox{
                    padding-bottom:40px;

              }
           .headerBox{
                font-size: 16px;
                color: #484848;
                font-weight: bold;
                // margin-top:40px;/
                margin-bottom:15px;
                @extend .display-fx-center;
                .line{
                  width: 4px;
                  height: 12px;
                  background: #5D85FF;
                  border-radius: 6px 6px 6px 6px;
                  margin-right:6px;
                }
             }
          }
          .bottomBtnCss{
            // margin-top: auto;
            text-align: right;
            position: fixed;
            bottom: 40px;
            right: 40px;
        }
        .preview{
              @extend .display-fx-center;  
              justify-content: center; 
        }
        .pagination{
              @extend .display-fx-center;  
              justify-content: center;   
              margin-top:50px;     
        }
        ::v-deep{  
           .el-table__header-wrapper th{
                 background: #F4F8FF!important;       
           }
            .el-image,.el-image__inner{
               width: 80px!important;
               height: 30px!important;
               }
        }
        
</style>
